{* $Id$ *}
{include_core file="admin/lib/header.html" title="抱抱币类型添加"}
<div class="page-header border-bottom clearfix">
  <h2 class="left">抱抱币类型管理<span>添加抱抱币类型</span></h2>
  <a href="{AnUrl('bbcoin/admin/bbcoin_type')}" class="btn btn-default btn-sm right">&lt;&nbsp;返回抱抱币类型列表</a>
</div>
<!--start:抱抱币类型新增-->
<div class="add-form">
  <form action="{if $bbcoin_type_info}{AnUrl('bbcoin/admin/bbcoin_type/update')}{else}{AnUrl('bbcoin/admin/bbcoin_type/create')}{/if}" method="post" enctype="multipart/form-data">
    <input type="hidden" name="id" value="{$bbcoin_type_info.id}">
    <table class="table" cellpadding="0" cellspacing="0" style="position:relative;">
      <tr style="position:relative;">
        <th><label for="" class="add-f-label">父级类型：</label></th>
        <td>
          {if $bbcoin_type_info}
            <input type="hidden" name="bbcoin_type[parent_id]" value="{$bbcoin_type_info.parent_id}">
            {$bbcoin_type_info.parent_res_name}
          {else}
            <select name="bbcoin_type[parent_id]" id="">
              <option value="0" selected>顶级分类</option>
              {foreach $parent_bbcoin_type_list as $k=>$v}
                <option value="{$v.id}">{$v.res_name}</option>
              {/foreach}
            </select>
          {/if}
        </td>
      </tr>
      <tr style="position:relative;">
        <th><label for="" class="add-f-label">抱抱币类型：</label></th>
        <td>
          <input name="bbcoin_type[res_name]" style="width:490px;" type="text" class="add-f-ipt1" maxlength="50" placeholder="输入抱抱币类型" value="{$bbcoin_type_info.res_name}" >
          <div class="tips"><span style="line-height: 34px;color: #f00;margin-right: 10px;">*</span>输入抱抱币类型</div>
        </td>
      </tr>
      
      <tr><th>&nbsp;</th><td class="noborder"><button type="submit" class="btn btn-success js_submit">&nbsp;&nbsp;&nbsp;{if $bbcoin_type_info}修改{else}添加{/if}&nbsp;&nbsp;&nbsp;</button></td></tr>
    </table>
  </form>
</div>
<!--end:抱抱币类型新增-->
<script>
$(function(){    
  // 提交验证
  $('.js_submit').click(function(){
    var bbcoin_type = $('input[name="bbcoin_type[res_name]"]').val();
    //验证
    if( !$.trim(bbcoin_type) ){
      showMsg('抱抱币类型不能为空!');
      return false;
    };

    var checkbbcoinType = true;

    //ajax验证此类型是否已经存在
    $.ajax({
      url : 'bbcoin/admin/bbcoin_type/bbcoin_type_exists?bbcoin_type='+bbcoin_type,
      type : 'get',
      async : false,
      success : function(res){
        if ( res != 'ok' ) {
          showMsg('此抱抱币类型已经存在,请重新填写');
          checkbbcoinType = false;
        };
      }
    });

    if (checkbbcoinType) {
      return true;
    };
    return false;
  });

});

</script>
{include_core file="admin/lib/footer.html"}